wx.getStorageSync("log");

var a = getApp();

Page({
    data: {
        curHdIndex: 1,
        judge: !0,
        judges: !1,
        id: 1,
        obj: [
          {
            nmOrdItemImg: "/assets/images/more.png",
            nmOrdItem:'维生素',
            nmFreq:'1天',
            numSingle:2,
            numSingleUnit:'颗',
            beginTime:'2018-10-24'
          },
          {
            nmOrdItemImg: "/assets/images/more.png",
            nmOrdItem: '维生素',
            nmFreq: '1天',
            numSingle: 2,
            numSingleUnit: '颗',
            beginTime: '2018-10-24'
          },
          {
            nmOrdItemImg: "/assets/images/more.png",
            nmOrdItem: '维生素',
            nmFreq: '1天',
            numSingle: 2,
            numSingleUnit: '颗',
            beginTime: '2018-10-24'
          }
        ],
        objx: [
          {
            id:1,
            nmTag:'维生素B',
            effectTimeString: '2018-10-24',
            content:'味道好'
          },
          {
            id: 1,
            nmTag: '维生素C',
            effectTimeString: '2018-10-24',
            content: '味道好'
          }
        ],
        objs: [
          {
            nmOrdItemImg: "/assets/images/more.png",
            nmOrdItem: '2018-10-24',
            nmFreq:1,
            numSingle:1,
            numSingleUnit:1,
            beginTime: '2018-10-24'
          },
          {
            nmOrdItemImg: "/assets/images/more.png",
            nmOrdItem: '2018-10-24',
            nmFreq: 1,
            numSingle: 1,
            numSingleUnit: 1,
            beginTime: '2018-10-24'
          }
        ],
        currentResult: 0,
        arr: [],
        index: ""
    },
    tabClick: function(a) {
        console.log(a.target.dataset.id);
        var t = a.target.dataset.id;
        this.setData({
            curHdIndex: a.target.dataset.id,
            id: t,
            noFlag: !1
        }), 1 == a.target.dataset.id ? (this.setData({
            judge: !0,
            judges: !1
        }), this.onClick1()) : 2 == a.target.dataset.id && (this.setData({
            judge: !1,
            judges: !0
        }), this.onClick2());
    },
    onClick1: function() {
        var t = this, e = wx.getStorageSync("patientId") || "", s = wx.getStorageSync("log") || "";
        console.log(e + "_" + s);
        var s = e + "_" + s + t.data.teamId, d = wx.getStorageSync("flag") || "";
        wx.request({
            url: a.globalData.patient + "patient/drugRecord/list/" + s + "/1/" + d,
            data: {},
            success: function(a) {
                console.log(a.data.data), a.data.data.length <= 0 ? wx.showToast({
                    title: "患者没有添加用药记录",
                    icon: "none",
                    duration: 2e3
                }) : t.setData({
                    obj: a.data.data
                });
            }
        });
    },
    onClick2: function() {
        var t = this, e = wx.getStorageSync("patientId") || "", s = wx.getStorageSync("log") || "";
        console.log(e + "_" + s);
        var s = e + "_" + s + t.data.teamId, d = wx.getStorageSync("flag") || "";
        wx.request({
            url: a.globalData.patient + "patient/drugRecord/list/" + s + "/0/" + d,
            data: {},
            success: function(a) {
                console.log(a.data), a.data.data.length <= 0 ? wx.showToast({
                    title: "患者没有添加用药记录",
                    icon: "none",
                    duration: 2e3
                }) : t.setData({
                    objs: a.data.data
                });
            }
        });
    },
    lower: function() {
        if (!this.data.noFlag && !this.data.closureFlag) {
            this.setData({
                closureFlag: !0
            });
            var t, e, s = this, d = this.data.currentResult, o = s.data.objx, n = s.data.arr;
            console.log(d);
            var g = wx.getStorageSync("patientId") || "", c = wx.getStorageSync("log") || "";
            console.log(g + "_" + c);
            var c = g + "_" + c + s.data.teamId, r = wx.getStorageSync("flag") || "";
            wx.request({
                url: a.globalData.patient + "patient/drugEffect/list/" + c + "/" + d + "/" + r,
                data: {},
                success: function(a) {
                    if (console.log(a), console.log(a.data.data.page.nextResult), 200 == a.data.code) {
                        s.setData({
                            currentResult: a.data.data.page.nextResult
                        });
                        var d = a.data.data.effects;
                        if (t = o.concat(d), console.log(d), console.log(t), a.data.data.effects.length == []) return s.setData({
                            noFlag: !0,
                            closureFlag: !1
                        }), !1;
                        wx.showLoading({
                            title: "加载中",
                            icon: "loading"
                        });
                        for (var g = [], c = 0; c < a.data.data.effects.length; c++) 270101 == a.data.data.effects[c].cdTag ? g.push("/assets/images/75.png") : 270102 == a.data.data.effects[c].cdTag ? g.push("/assets/images/73.png") : 270103 == a.data.data.effects[c].cdTag ? g.push("/assets/images/83.png") : 270104 == a.data.data.effects[c].cdTag && g.push("/assets/images/84.png");
                        e = n.concat(g), s.setData({
                            objx: t,
                            arr: e,
                            closureFlag: !1
                        }), setTimeout(function() {
                            wx.hideLoading();
                        }, 1500);
                    }
                },
                fail: function() {
                    wx.showToast({
                        title: "系统繁忙，请稍后重试",
                        icon: "none",
                        duration: 2e3
                    }), s.setData({
                        closureFlag: !1
                    });
                }
            });
        }
    },
    onClickadd: function() {
        var t = this, e = wx.getStorageSync("patientId") || "", s = wx.getStorageSync("log") || "";
        console.log(e + "_" + s);
        var s = e + "_" + s + t.data.teamId, d = wx.getStorageSync("flag") || "";
        wx.request({
            url: a.globalData.patient + "patient/drugEffect/list/" + s + "/0/" + d,
            data: {},
            success: function(a) {
                console.log(a.data);
                for (var e = [], s = 0; s < a.data.data.effects.length; s++) 270101 == a.data.data.effects[s].cdTag ? e.push("/assets/images/75.png") : 270102 == a.data.data.effects[s].cdTag ? e.push("/assets/images/73.png") : 270103 == a.data.data.effects[s].cdTag ? e.push("/assets/images/83.png") : 270104 == a.data.data.effects[s].cdTag && e.push("/assets/images/84.png");
                t.setData({
                    objx: a.data.data.effects,
                    arr: e,
                    currentResult: a.data.data.page.nextResult
                });
            }
        });
    },
    onLoad: function(a) {
        var t = this;
        t.setData({
            teamId: a.teamId || ""
        }), t.onClick1(), t.onClickadd(), wx.getSystemInfo({
            success: function(a) {
                t.setData({
                    height: a.windowHeight
                });
            }
        });
    },
    seet: function(a) {
        wx.navigateTo({
          url: "/hyb_yl/backstageFollowUp/pages/pharmacyseet/pharmacyseet?teamId=" + this.data.teamId
        });
    },
    alter: function(a) {
        console.log(a.currentTarget.dataset.id);
        var t = a.currentTarget.dataset.id;
        wx.setStorageSync("drugId", t), wx.navigateTo({
          url: "/hyb_yl/index/pharmacyAlter/pharmacyAlter"
        });
    },
    navClick: function(a) {
        console.log(a.currentTarget.dataset.id), wx.setStorageSync("effectId", a.currentTarget.dataset.id), 
        wx.navigateTo({
          url: "/hyb_yl/backstageFollowUp/pages/pharmacyAddresult/pharmacyAddresult?teamId=" + this.data.teamId
        });
    }
});